package main

import "fmt"

func create() {
	m := map[string]string{
		"name":   "张三",
		"course": "golang",
	}

	m2 := make(map[string]int)
	var m3 map[string]int
	fmt.Println(m, m2, m3)

	fmt.Println("遍历，map是无序的--------------")
	for k, v := range m {
		fmt.Println(k, v)
	}

	fmt.Println("获取值,如果key值map中不存在，会输出0值------------")
	fmt.Println(m["name"])
	fmt.Println(m2["test"])

	fmt.Println("判断key值是否存在-------------------------")
	test, ok := m2["test"]
	fmt.Println(test, ok)
	if _, ok := m["test"]; !ok {
		fmt.Println("key不存在")
	}

	fmt.Println("删除-----------------")
	name, ok := m["name"]
	fmt.Println(name, ok)
	delete(m, "name")
	fmt.Println(m)
}

func main() {
	create()
}
